<template>
  <div class="directive-demo">
    <h1>Vue 固定区域拖拽指令演示</h1>
    <p class="description">使用 v-drag 指令实现元素在父容器内的拖拽</p>
    
    <!-- 拖拽演示 -->
    <section class="demo-section">
      <h2>拖拽演示</h2>
      <div class="demo-container">
        <div class="drag-area">
          <div v-drag class="drag-box">
            拖拽我
          </div>
        </div>
      </div>
    </section>

    <!-- 使用说明 -->
    <section class="demo-section">
      <h2>使用说明</h2>
      <div class="usage-info">
        <h3>基本用法：</h3>
        <pre><code>&lt;div v-drag&gt;拖拽元素&lt;/div&gt;</code></pre>
        
        <h3>特点：</h3>
        <ul>
          <li>元素只能在父容器内拖拽</li>
          <li>支持鼠标和触摸操作</li>
          <li>拖拽时自动限制边界</li>
          <li>拖拽过程中有视觉反馈</li>
        </ul>
      </div>
    </section>
  </div>
</template>

<script>
export default {
  name: 'DirectiveDemo'
}
</script>

<style scoped>
.directive-demo {
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
}

.directive-demo h1 {
  text-align: center;
  color: #333;
  margin-bottom: 10px;
}

.description {
  text-align: center;
  color: #666;
  margin-bottom: 30px;
}

.demo-section {
  margin-bottom: 30px;
  padding: 20px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fafafa;
}

.demo-section h2 {
  color: #555;
  margin-bottom: 15px;
  font-size: 18px;
}

.demo-container {
  position: relative;
  min-height: 200px;
  background: white;
  border-radius: 4px;
  padding: 20px;
}

/* 拖拽区域 */
.drag-area {
  position: relative;
  width: 100%;
  height: 200px;
  border: 2px dashed #ccc;
  border-radius: 8px;
  background: #f8f9fa;
}

/* 拖拽元素 */
.drag-box {
  position: absolute;
  width: 100px;
  height: 60px;
  background: #007bff;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  top: 20px;
  left: 20px;
}

/* 使用说明 */
.usage-info {
  background: white;
  padding: 20px;
  border-radius: 4px;
}

.usage-info h3 {
  color: #333;
  margin-bottom: 10px;
  font-size: 16px;
}

.usage-info pre {
  background: #f8f9fa;
  padding: 10px;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 15px;
}

.usage-info code {
  color: #e83e8c;
  font-family: 'Courier New', monospace;
}

.usage-info ul {
  margin: 0;
  padding-left: 20px;
}

.usage-info li {
  margin-bottom: 5px;
  color: #666;
}

/* 响应式 */
@media (max-width: 768px) {
  .directive-demo {
    padding: 10px;
  }
  
  .demo-section {
    padding: 15px;
  }
  
  .drag-box {
    width: 80px;
    height: 50px;
    font-size: 12px;
  }
}
</style>
